﻿using System;
using System.Collections.Generic;
using Framework;

namespace Enterprise.Admin.Handle
{
    /// <summary>
    /// 获取产品资料详细
    /// </summary>
    public partial class GetProductDetailJson : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var list = new List<object>();
            var id = Fq("id").SafeToInt();
            var productService = new ProductService();
            var row = productService.GetById(id);
            object result = new
                                {
                                    CoProductId = row["CoProductId"].SafeToInt(),
                                    CoName = row["CoName"].SafeToString(),
                                    CoNameEn = row["CoNameEn"].SafeToString(),
                                    CoIsRecommend = row["CoIsRecommend"].SafeToInt(),
                                    CoProductCategoryId = row["CoProductCategoryId"].SafeToString(),
                                    CoDescription = row["CoDescription"].SafeToString(),
                                    CoDescriptionEn = row["CoDescriptionEn"].SafeToString(),
                                    CoCoverImageId = row["CoCoverImageId"].SafeToInt(),
                                    CoModel = row["CoModel"].SafeToString(),
                                    CoModelEn = row["CoModelEn"].SafeToString(),
                                    CoKeyword = row["CoKeyword"].SafeToString(),
                                    CoFinish = row["CoFinish"].SafeToString(),
                                    CoMaterial = row["CoMaterial"].SafeToString(),
                                    CoDoorThickness = row["CoDoorThickness"].SafeToString(),
                                    CoBackset = row["CoBackset"].SafeToString(),
                                    CoAvailableFor = row["CoAvailableFor"].SafeToString(),
                                    CoApplicableStndard = row["CoApplicableStndard"].SafeToString(),
                                    CoKeywordEn = row["CoKeywordEn"].SafeToString(),
                                    CoFinishEn = row["CoFinishEn"].SafeToString(),
                                    CoMaterialEn = row["CoMaterialEn"].SafeToString(),
                                    CoAvailableForEn = row["CoAvailableForEn"].SafeToString(),
                                    CoSize = row["CoSize"].SafeToString(),
                                    CoSummary = row["CoSummary"].SafeToString(),
                                    CoSummaryEn = row["CoSummaryEn"].SafeToString(),
                                    ProductImage = list
                                };
            var productImageService = new ProductImageService();
            var dr = productImageService.GetTable(id).Rows;
            for (int i = 0; i < dr.Count; i++)
            {
                list.Add(
                    new
                        {
                            id = dr[i]["CoProductImageId"].SafeToInt(),
                            CoProductImageId = dr[i]["CoProductImageId"].SafeToInt(),
                            CoSmallImage = dr[i]["CoSmallImage"].SafeToString(),
                            CoNormalImage = dr[i]["CoNormalImage"].SafeToString(),
                            thumFileName = dr[i]["CoSmallImage"].SafeToString(),
                            CoBigImage = dr[i]["CoBigImage"].SafeToString(),
                        });

            }
            Json(result);
        }
    }
}